/*
  Blowfish algorithm.  Written 1997 by by Paul Kocher
  (pck@netcom.com).  The Blowfish algorithm is public domain.
*/
// modified for CheezyCrypt
#ifndef ___BLOWFISH_H___
#define ___BLOWFISH_H___

#ifdef __cplusplus
extern "C" {
#endif
#define BLOWFISH_BIG_ENDIAN 1
#ifdef BLOWFISH_BIG_ENDIAN
struct WordByte
{
	unsigned int zero:8;
	unsigned int one:8;
	unsigned int two:8;
	unsigned int three:8;
};

#else
//little endian
struct WordByte
{
	unsigned int three:8;
	unsigned int two:8;
	unsigned int one:8;
	unsigned int zero:8;
}WordByte;
#endif

union Word
{
	unsigned long word;
	struct WordByte byte;
};

struct DWord
{
	union Word word0;
	union Word word1;
};


#define MAX_BLOW_STRING   256
#define MAX_BLOW_PASSWD   56  // 448bits

typedef struct {
  unsigned long P[16 + 2];
  unsigned long S[4][256];
}BlowCtx;


//NOTE all lengths must be a multiple of 16 bytes
void BlowSetKey( BlowCtx *pgBlowCtx, unsigned char *pu8Passwd, int iLen );
void BlowEncrypt( BlowCtx * pgBlowCtx, unsigned char * pu8Data, int iLen );
void BlowDecrypt( BlowCtx * pgBlowCtx, unsigned char * pu8Data, int iLen );


#ifdef __cplusplus
}  /* extern "C" */
#endif


#endif //___BLOWFISH_H___

